home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-05-21 | 4.1 KB | 115 lines | [TEXT/ttxt] |
- in module BitmapMenuModule
-
- --*******************************************************************************
- --* Class name: MenuButton
- --*
- --* Inherits from: TwoDShape and Actuator
- --* Class type: Concrete
- --* Component: User Interface
- --*
- --* Description: This is a subclass of TwoDShape and Button which
- --* facilitates the creation of hierarchical bitmap menus.
- --* Top level menus and submenus are created in very much
- --* the same way. The only difference lies with the values
- --* of the supermenu and newMenu keywords. For top level
- --* menus, set supermenu to UNDEFINED and newMenu to TRUE.
- --* For submenus, set supermenu to its parent menu and newMenu
- --* to FALSE. To add new items (non menus) to the menu, use
- --* the addMenuItem method.
- --*
- --* Usage: main menubutton -
- --* mb := new MenuButton supermenu:UNDEFINED \
- --* newMenu:TRUE \
- --* sub menubutton -
- --* smb := new MenuButton supermenu:mb \
- --* newMenu:FALSE \
- --* menu items -
- --* addmenuitem supermenu label authordata activateAction
- --*
- --* IVs: authordata
- --* activateAction
- --*
- --* Methods: addMenuItem
- --* init
- --*
- --* Required files: reqFiles/button.sx
- --*
- --* Notes: If the action to be performed is a method, it must be
- --* defined as a method of the authordata.
- --*
- --* Also refer to textmenu.sx. Notice the similarities in the
- --* way the 2 versions of MenuButton are implemented.
- --*
- --* Author: Su Quek - Kaleida Labs, Inc.
- --*******************************************************************************
- class MenuButton (TwoDShape, Button)
- inst vars
- authordata
- activateAction
- end
-
- --*=============================================================================*
- --* Method name: addMenuItem
- --* Class: MenuButton
- --* Usage: addmenuitem self relBMP prsBMP authordata activateAction
- --* relBMP - Bitmap object
- --* prsBMP - Bitmap object
- --* authordata - object
- --* activateAction - function
- --* Notes: If the activateAction is a method, it must be defined as a
- --* method of the authordata.
- --*-----------------------------------------------------------------------------*
- --* Description: Adds a terminal button (one which does not invoke another
- --* menu) and sets its authordata and action.
- --*=============================================================================*
- method addMenuItem self {class MenuButton} relBMP prsBMP authordata action ->
- (
- local menuItem := new MenuButton supermenu:self \
- newMenu:false \
- releasedBitmap: relBMP \
- pressedBitmap: prsBMP
- menuItem.authordata := authorData
- menuItem.activateAction := action
-
- return menuItem
- )
-
- --*=============================================================================*
- --* Method name: afterInit
- --* Class: MenuButton
- --* Usage: afterInit self [supermenu:<MenuButton>]
- --* [newMenu:<Boolean>]
- --* [placement:<NameClass>]
- --* - (@menuDown, @menuRight, @menuAtPointer)
- --*-----------------------------------------------------------------------------*
- --* Description: Adds the button to its supermenu or creates it's submenu
- --* as appropriate.
- --*=============================================================================*
- method afterInit self {class MenuButton} #rest args #key supermenu:(undefined) \
- newMenu:(true) \
- placement:(@menuDown) ->
- (
- nextmethod self
-
- --*=========================================================================*
- --* Create a submenu for this button
- --*=========================================================================*
- if newMenu do
- (
- local subMenu := new menu
- subMenu.placement := placement
- self.menu := subMenu
- )
-
- --*=========================================================================*
- --* Add this button to its supermenu
- --*=========================================================================*
- if (supermenu <> undefined) do
- append supermenu.menu self
-
- return self
- )
-
- "Loaded hiermenu.sx"
-
-